﻿//Copyright (C) <2013>  <jonathan cleeve norton> All Rights Reserved 
//Contact jon.norton@fin-plus.co.uk website <http://www.fin-plus.co.uk/>
using System;
using FinPlusCompCore;
using QLNet;
using p = FinPlusCompQuant.QLConvParser;

namespace FinPlusCompQuant
{
    public class FlatForwardCurve : FinPlusComponent
    {
        public FlatForward FlatForward { get; private set; }
        public SwapEngine SwapEngine { get; private set; }

        //construct
        public FlatForwardCurve(Market market, string name, string discountCurveName, DateTime settlementDate, double rate, string dayCount, string holidays = "")
        {
            Id = name;
            var calendar = p.Calendar(holidays);
		    
		    FlatForward = new FlatForward(calendar.adjust(settlementDate), new Handle<Quote>(new SimpleQuote(rate)), p.DayCount(dayCount));
            SwapEngine = new SwapEngine(market, name, discountCurveName == "" ? name : discountCurveName);
        }

        public FlatForwardCurve(Market market, string name, string discountCurveName, DateTime settlementDate, double rate, string dayCount, string cpnFrq, string compounding, string holidays = "")
        {
            Id = name;
            var calendar = p.Calendar(holidays);
    
		    FlatForward = new FlatForward(calendar.adjust(settlementDate), new Handle<Quote>(new SimpleQuote(rate)), p.DayCount(dayCount),
                p.Compounding(compounding), p.Freq(cpnFrq));

            SwapEngine = new SwapEngine(market, name, discountCurveName == "" ? name : discountCurveName);
        }
    }
}
